package com.halfsword.creativecraft.modules;

import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.capability.templates.FluidTank;

import java.util.function.Predicate;

public class BaseFluidTank extends FluidTank {
    private final String name;
    private final Predicate<FluidStack> validator;

    public BaseFluidTank(String name, int capacity) {
        this(name, capacity, fluid -> true);
    }

    public BaseFluidTank(String name, int capacity, Predicate<FluidStack> validator) {
        super(capacity);
        this.name = name;
        this.validator = validator;
    }

    @Override
    public int getCapacity() {
        return super.getCapacity();
    }

    @Override
    public boolean isFluidValid(FluidStack stack) {
        return validator.test(stack) && super.isFluidValid(stack);
    }

    public String getName() {
        return name;
    }

    public int getFluidAmount() {
        return getFluid().getAmount();
    }

    // 不需要重写 writeToNBT 和 readFromNBT，直接使用父类的实现
}